<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
 * FCKeditor - The text editor for Internet - http://www.fckeditor.net
 * Copyright (C) 2003-2007 Frederico Caldeira Knabben
 *
 * == BEGIN LICENSE ==
 *
 * Licensed under the terms of any of the following licenses at your
 * choice:
 *
 *  - GNU General Public License Version 2 or later (the "GPL")
 *    http://www.gnu.org/licenses/gpl.html
 *
 *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
 *    http://www.gnu.org/licenses/lgpl.html
 *
 *  - Mozilla Public License Version 1.1 or later (the "MPL")
 *    http://www.mozilla.org/MPL/MPL-1.1.html
 *
 * == END LICENSE ==
 *
 * File Name: fck_placeholder.html
 * 	Placeholder Plugin.
 *
 * File Authors:
 * 		Frederico Caldeira Knabben (www.fckeditor.net)
-->
<html>
	<head>
		<title>Placeholder Properties</title>
		<base href="http://<?php echo WSB_HOST . WSB_ADMIN_URL ?>" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta content="noindex, nofollow" name="robots">
    	<script type="text/javascript" src="../WSB/library/WSB/Js/XMLHttpRequest.js"></script>
	   <script type="text/javascript" src="../WSB/library/WSB/Js/httpRequest.js"></script>
		<script language="javascript">

var oEditor = window.parent.InnerDialogLoaded() ;
var FCKLang = oEditor.FCKLang ;
var FCKPlaceholders = oEditor.FCKPlaceholders ;

window.onload = function ()
{
	// First of all, translate the dialog box texts
	oEditor.FCKLanguageManager.TranslatePage( document ) ;

	LoadSelected() ;

	// Show the "Ok" button.
	window.parent.SetOkButton( true ) ;
}

var eSelected = oEditor.FCKSelection.GetSelectedElement() ;

function LoadSelected()
{
	if ( !eSelected )
		return ;

	if ( eSelected.tagName == 'SPAN' && eSelected._fckplaceholder ) {

        // Ajaxthread starten
        httpRequest("GET", "http://<?php echo WSB_HOST . WSB_ADMIN_URL ?>placeholder/index/ajax-get/id/" + eSelected._fckplaceholder, true, function() {
            if(request.readyState == 4) {
                var obj = eval("(" + request.responseText + ")");
    			document.getElementById('txtID').value = obj.id ;
    			document.getElementById('txtName').value = obj.name ;
    			document.getElementById('txtDescription').value = obj.description ;
            }
        });

	} else {
		eSelected == null ;
	}
}

function Ok()
{
	var sID = document.getElementById('txtID').value ;
	var sValue = document.getElementById('txtName').value ;
    var sDescription = document.getElementById('txtDescription').value ;
    // Name validieren
    if ( sValue.length == 0 ) {
		alert( FCKLang.PlaceholderErrNoName ) ;
		return false ;
	}

    // Ajaxthread starten
    var data = "id=" + escape(sID) + "&name=" + escape(sValue) + "&description=" + escape(sDescription);
    httpRequest("POST", "http://<?php echo WSB_HOST . WSB_ADMIN_URL ?>placeholder/index/ajax-add/", true, function() {
        if(request.readyState == 4) {
            var obj = eval("(" + request.responseText + ")");
        	if (!obj.id )
        	{
        		alert( 'Platzhalter konnte nicht erzeugt werden (Datenbank-Fehler)') ;
        		return ;
        	}
            FCKPlaceholders.Add( obj.id ) ;

            // Ohne Timeout wird das Fenster nicht geschlossen
	        window.setTimeout("top.close()", 500);

        }
    }, data);

	// Fenster schliessen
	return false;
}

		</script>
	</head>
	<body scroll="no" style="OVERFLOW: hidden">

		<table height="100%" cellSpacing="0" cellPadding="0" width="100%" border="0">
			<tr>
				<td>
					<table cellSpacing="0" cellPadding="0" align="center" border="0">
						<tr>
							<td>
								<input id="txtID" type="hidden"><br>
								<span fckLang="PlaceholderDlgName">Placeholder Name</span><br>
								<input id="txtName" type="text"><br>

								<span fckLang="PlaceholderDlgDescription">Placeholder Description</span><br>
								<textarea id="txtDescription"></textarea>
								<div id="Debug" style="margin-top:1em;"></div>
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</body>
</html>